﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DiveManager
{
    public partial class SupplierHistoryListed : Form
    {
        public string id_search;

        protected DiveDatabaseEntities diveDatabase;
        protected BindingSource bindingSource;
        
        
        public SupplierHistoryListed()
        {
            InitializeComponent();

            // Init Database
            diveDatabase = new DiveDatabaseEntities();
            bindingSource = new BindingSource();
        }

        private void SupplierHistoryListed_Load(object sender, EventArgs e)
        {
            this.id_search = Weitergabe_Details;

            LoadData();


        }
        public string Weitergabe_Details
        {
            get;
            set;
        }

        protected void LoadData()
        {
            Guid id_guid = new Guid(id_search);
            IQueryable<Supplier_HistoryDetails> dataQuery = from sh in diveDatabase.Supplier_HistoryDetails
                                                            where sh.History_ID == id_guid
                                                            select sh;

            // Bind Data to BindingSource
            bindingSource.DataSource = dataQuery;

            // Bind BindingSource to List
            HistoryList.DataSource = bindingSource;


            // Hide ID-Columns
            HistoryList.Columns["ID"].Visible = false;
            HistoryList.Columns["History_ID"].Visible = false;
            HistoryList.Columns["Changed"].Visible = true;
            HistoryList.Columns["Old"].Visible = true;
            HistoryList.Columns["New"].Visible = true;



            // Set Column Headers
            HistoryList.Columns["Changed"].HeaderText = "Änderungen";
            HistoryList.Columns["Old"].HeaderText = "Vorgänger Version";
            HistoryList.Columns["New"].HeaderText = "Aktuelle Version";
        }
    }
}
